﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Site1.Master" AutoEventWireup="true" CodeBehind="ShoppingCart.aspx.cs" Inherits="EWDTAssignment.ShoppingCart" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <style type="text/css">
        .style1
        {
            text-align: left;
        }
        .style2
        {
            font-size: medium;
        }
        .style3
        {
            font-family: "Times New Roman", Times, serif;
        }
    </style>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
   
    <h3>Your Shopping Cart<asp:ScriptManager ID="ScriptManager1" runat="server">
        </asp:ScriptManager>
    </h3>
 
   
     
   
        <asp:UpdatePanel ID="UpdatePanel1" runat="server">
            <ContentTemplate>
               <asp:Panel ID="Panel1" runat="server" ScrollBars="Vertical" Height="435px" 
                    Width="100%">
                    <div style="text-align:center; height: 135px;">
                    
                <asp:GridView ID="gvShoppingCart" runat="server" 
                    AllowSorting="True" AutoGenerateColumns="False" DataSourceID="dsCartItem" 
                    onrowcommand="gvShoppingCart_RowCommand" 
                    onrowcreated="gvShoppingCart_RowCreated" PageSize="999999" ShowFooter="True" 
                    GridLines="Horizontal" HorizontalAlign="Justify" 
                    onrowediting="gvShoppingCart_RowEditing" 
                    onrowupdated="gvShoppingCart_RowUpdated" 
                    onrowupdating="gvShoppingCart_RowUpdating" ShowHeaderWhenEmpty="True" 
                    Width="95%" onrowdatabound="gvShoppingCart_RowDataBound" 
                    BackColor="#66CCFF" 
                    onselectedindexchanged="gvShoppingCart_SelectedIndexChanged">
                    <Columns>
                        <asp:TemplateField HeaderText="Select All">
                            <EditItemTemplate>
                                <asp:CheckBox ID="ck1" runat="server" style="text-align: center" 
                                    Width="20px" />
                                <br />
                                <asp:Label ID="lblProductID" runat="server" Text='<%# Eval("ProductID") %>' 
                                    Visible="False"></asp:Label>
                                <br />
                            </EditItemTemplate>
                            <FooterTemplate>
                                <asp:CheckBox ID="ckSelectAll" runat="server" AutoPostBack="True" Height="16px" 
                                    oncheckedchanged="ckSelectAll_CheckedChanged" style="text-align: center" 
                                    Width="20px" Checked="True" />
                            </FooterTemplate>
                            <HeaderTemplate>
                                <asp:CheckBox ID="ckSelectAll" runat="server" 
                                    oncheckedchanged="ckSelectAll_CheckedChanged" 
                                    AutoPostBack="True" style="text-align: center" Width="20px" 
                                    Checked="True" />
                            </HeaderTemplate>
                            <ItemTemplate>
                                <asp:CheckBox ID="ck1" runat="server" Width="20px" style="text-align: center" 
                                    AutoPostBack="True" Checked="True" oncheckedchanged="ck1_CheckedChanged" />
                                <asp:Label ID="lblProductID" runat="server" Text='<%# Eval("ProductID") %>' 
                                    Visible="False"></asp:Label>
                                <br />
                       
                            </ItemTemplate>
                        </asp:TemplateField>
                        <asp:TemplateField HeaderText="Product">
                            <EditItemTemplate>
                                <asp:ImageButton ID="ImgProduct" runat="server" Height="50px" 
                                    ImageAlign="AbsMiddle" ImageUrl='<%# Eval("ProdImg") %>' 
                                 
                                    PostBackUrl='<%# String.Format("~/ProductInfo.aspx?ProductID={0}", Eval("ProductID")) %>' 
                                    Width="96px" />
                            </EditItemTemplate>
                            <FooterTemplate>
                                <div class="style1">
                                    <strong>Selected</strong><asp:ImageButton ID="imgBtnDelete" runat="server" 
                                        ImageAlign="AbsMiddle" ImageUrl="~/images/DeleteCartbtn.png" 
                                        onclick="imgBtnDelete_Click" Width="120px" />
                                </div>
                            </FooterTemplate>
                            <HeaderTemplate>
                                <div class="style1">
                                    Select All</div>
                            </HeaderTemplate>
                            <ItemTemplate>
                                <asp:ImageButton ID="ImgProduct0" runat="server" Height="50px" 
                                    ImageAlign="AbsMiddle" ImageUrl='<%# Eval("ProdImg") %>' 
                                  
                                    PostBackUrl='<%# String.Format("~/ProductInfo.aspx?ProductID={0}", Eval("ProductID")) %>' 
                                    Width="96px" />
                            </ItemTemplate>
                        </asp:TemplateField>
                        <asp:TemplateField>
                            <EditItemTemplate>
                                <asp:LinkButton ID="lkbtnPName" runat="server" onclick="lkbtnPName_Click" 
                                    PostBackUrl='<%# String.Format("~/ProductInfo.aspx?ProductID={0}", Eval("ProductID")) %>' 
                                    Text='<%# Bind("ProductName") %>' Width="70px"></asp:LinkButton>
                            </EditItemTemplate>
                            <HeaderTemplate>
                                Product
                            </HeaderTemplate>
                            <ItemTemplate>
                                <asp:LinkButton ID="lkbtnPName" runat="server" onclick="lkbtnPName_Click" 
                                    PostBackUrl='<%# String.Format("~/ProductInfo.aspx?ProductID={0}", Eval("ProductID")) %>' 
                                    Text='<%# Bind("ProductName") %>' Width="150px"></asp:LinkButton>
                            </ItemTemplate>
                        </asp:TemplateField>
                        <asp:TemplateField HeaderText="Price">
                            <EditItemTemplate>
                                <strong>SGD: $</strong><asp:Label ID="lblPrice" runat="server" Text='<%# Bind("Price") %>'></asp:Label>
                            </EditItemTemplate>
                            <ItemTemplate>
                                <strong>SGD: $</strong><asp:Label ID="lblPrice" runat="server" 
                                    Text='<%# Bind("Price") %>'></asp:Label>
                            </ItemTemplate>
                        </asp:TemplateField>
                        <asp:TemplateField HeaderText="Quantity">
                            <EditItemTemplate>
                                <asp:TextBox ID="txtBoxQty" runat="server" Height="22px" 
                                    Text='<%# Eval("CartQty") %>' Width="36px"></asp:TextBox>
                                <br />
                                <asp:LinkButton ID="LinkbtnCancelCart" runat="server" CausesValidation="False" 
                                   Text="Update" 
                                    onclick="LinkbtnCancelCart_Click" CommandName="Update" 
                                    CommandArgument="Update"></asp:LinkButton>
                            </EditItemTemplate>
                            <FooterTemplate>
                                <asp:ImageButton ID="ImageButton1" runat="server" Height="29px" 
                                    ImageAlign="Right" ImageUrl="~/images/checkoutBtn.png" 
                                    onclick="ImageButton1_Click" Width="95px" />
                            </FooterTemplate>
                            <ItemTemplate>
                                <br />
                                <asp:Label ID="lblcartQty" runat="server" Text='<%# Bind("cartQty") %>' 
                                    style="font-weight: 700; font-size: 12px"></asp:Label>
                                <br />
                                <asp:LinkButton ID="LinkbtnEditCart" runat="server" CausesValidation="False" 
                                    CommandName="Edit" onclick="LinkbtnEditCart_Click" Text="Edit"></asp:LinkButton>
                            </ItemTemplate>
                        </asp:TemplateField>
                        <asp:TemplateField HeaderText="Total item Price">
                            <EditItemTemplate>
                                <strong>SGD: </strong>$<asp:Label ID="lbltotalItemPrice" runat="server"></asp:Label>
                            </EditItemTemplate>
                            <FooterTemplate>
                                <div class="style1">
                                    <span class="style3"><strong><span class="style2">Grand Total SGD: $</span></strong><span class="style2"><asp:Label 
                                        ID="lblgrdTotal" runat="server" Text="Label"></asp:Label>
                                    </span></span>
                                </div>
                            </FooterTemplate>
                            <ItemTemplate>
                                <strong>SGD: $</strong><asp:Label ID="lbltotalItemPrice" runat="server"></asp:Label>
                            </ItemTemplate>
                        </asp:TemplateField>
                    </Columns>
                    <FooterStyle HorizontalAlign="Center" VerticalAlign="Middle" />
                    <HeaderStyle Font-Bold="True" Font-Names="Century" HorizontalAlign="Left" 
                        Wrap="True" />
                    <PagerSettings Mode="NextPrevious" />
                    <PagerStyle HorizontalAlign="Center" VerticalAlign="Middle" />
                    <RowStyle HorizontalAlign="Justify" VerticalAlign="Middle" Wrap="True" 
                        Width="100px" />
                </asp:GridView>
                 </div>

                <br />
                <br />
                <br />
                    </asp:Panel>                          
                
        
            </ContentTemplate>
      
    </asp:UpdatePanel>
                
        <br />
        <br />
        <br />
     
        <br />
        <br />
        <br />
        <br />
        <br />


        <asp:ObjectDataSource ID="dsCartItem" runat="server" 
            OldValuesParameterFormatString="original_{0}" SelectMethod="getCartItemByAccID" 
            TypeName="EWDTAssignment.App_Code.DBManager" 
        UpdateMethod="EditQtyInCartItem">
            <SelectParameters>
                <asp:SessionParameter Name="AccountID" SessionField="accountID" Type="Int32" />
            </SelectParameters>
            <UpdateParameters>
           
                <asp:Parameter Name="AccountID" Type="Int32" />
                <asp:Parameter Name="pID" Type="Int32" />
                <asp:Parameter Name="productName" Type="String" />
                <asp:Parameter Name="price" Type="Double" />
           
                <asp:Parameter Name="CartQty" Type="Int32" />
<asp:Parameter Name="totalItemPrice" Type="Double"></asp:Parameter>
           
          </UpdateParameters>
        </asp:ObjectDataSource>
    



</asp:Content>






